<?php 

class chinatemplate  {


	public function insert($templateId,$province,$city,$morethan,$productId,$price,$postFee){
		DB::insert("syschinatemplate",array('templateId','province','city','morethan','productId','price','postFee'))
				->values(array(	$templateId,$province,$city,$morethan,$productId,$price,$postFee))
				->execute();
	}

	public function getByProductId($id){
		$result = DB::query(Database::SELECT,
	         'select  syschinatemplate.*,china.`Name` as cityshow,syschina.`Name` as provinceshow   from syschinatemplate  inner join syschina on(syschina.id=syschinatemplate.province) inner join  syschina   as china on(china.id = syschinatemplate.city)  where syschinatemplate.productId=  '.$id)->execute()->as_array();
		
		return $result;
	}

	public function delete($parm){

   		DB::delete('syschinatemplate')->where('productId','=',$parm['id'])->execute();
	}

	public function getchinatemplate($parm){
		$result = DB::select('*')->from('syschinatemplate')->where('province',"=",0)->and_where('city',"=",0)->and_where('productId',"=",$parm['productId'])->execute()->as_array();
		return $result;
	}


	public function getByParm($parm){
		$result = DB::select('*')->from('syschinatemplate')->where('province',"=",$parm['province'])->and_where('city',"=",$parm['city'])->and_where('productId',"=",$parm['productId'])->execute()->as_array();
		return $result;
	}
}